using System;
using System.Collections.Generic;
using System.Text;

namespace XiaoGang.Soft.XGWMS.DAL_SQL
{
    public class DAL_M006_GOODS_GROUP_SQL
    {
        #region SQL

        #region EXIST_GOODS_GROUP_SQL

        private static string _exist_GOODS_GROUP_SQL = @"SELECT GOODS_GROUP_ID
            FROM    [M006_GOODS_GROUP]
            WHERE   GOODS_GROUP_ID = @GOODS_GROUP_ID";

        #endregion

        #region CHECK_NAME_SQL
        private static string _check_Nmae_SQL = @"SELECT [GOODS_GROUP_ID]
    ,[GOODS_GROUP_NM]                     
FROM  [M006_GOODS_GROUP]
WHERE 1=1 ";
        #endregion

        #region GOODS_GROUP_DELETE_CHECK_SQL
        private static string _goods_Group_Delete_Check_SQL = @"SELECT	DISTINCT GOODS_GROUP
    FROM	M007_GOODS 
    WHERE	GOODS_GROUP = @GOODS_GROUP ORDER BY  GOODS_GROUP";
            
        #endregion

        #region GET_SINGLE_DATA_SQL

        private static string _get_Single_Data_SQL = @"
            SELECT 
                     [GOODS_GROUP_ID]
                    ,[GOODS_GROUP_NM]
                    ,[OrderNum]
                    ,[MEMO]
            FROM     [M006_GOODS_GROUP]
            WHERE    GOODS_GROUP_ID = @GOODS_GROUP_ID
            AND      TRANS_STATE <> 3";

        #endregion 

        #region INSERT_GOODS_GROUP_SQL

        private const string _insert_GOODS_GROUP_SQL = @"INSERT INTO [M006_GOODS_GROUP]
           ([CREATE_DATETIME]
           ,[UPDATE_DATETIME]
           ,[TRANS_STATE]
           ,[UPDATER_ID]
           ,[TERMINAL_CD]
           ,[GOODS_GROUP_ID]
           ,[GOODS_GROUP_NM]
           ,[OrderNum]
           ,[MEMO]
            )VALUES(
            CONVERT(VARCHAR,GETDATE(),112) + REPLACE(CONVERT(VARCHAR,GETDATE(),108),':','')
           ,CONVERT(VARCHAR,GETDATE(),112) + REPLACE(CONVERT(VARCHAR,GETDATE(),108),':','')
           ,'1'
           ,@UPDATER_ID
           ,@TERMINAL_CD
           ,@GOODS_GROUP_ID
           ,@GOODS_GROUP_NM
           ,(case when isnull(@OrderNum,-99)=-99 then (select max(OrderNum)+1 from M006_GOODS_GROUP) else @OrderNum end)
           ,@MEMO )";

        #endregion

        #region INSERT_GOODS_NO_SQL

        private const string _insert_GOODS_NO_SQL = @"INSERT INTO [M013_GoodSNo]  (GoodsID,GoodsNo)VALUES(@GOODS_ID,@GOODS_NO)";

        #endregion

        #region UPDATE_GOODS_GROUP_SQL

        private const string _update_GOODS_GROUP_SQL = @"UPDATE [M006_GOODS_GROUP]
           SET [UPDATE_DATETIME] = CONVERT(VARCHAR,GETDATE(),112) + REPLACE(CONVERT(VARCHAR,GETDATE(),108),':','')
              ,[TRANS_STATE] = '2'
              ,[UPDATER_ID] = @UPDATER_ID
              ,[TERMINAL_CD] = @TERMINAL_CD
              ,[GOODS_GROUP_ID] = @GOODS_GROUP_ID
              ,[GOODS_GROUP_NM] = @GOODS_GROUP_NM
              ,[OrderNum] = (case when isnull(@OrderNum,-99)=-99 then (select max(OrderNum)+1 from M006_GOODS_GROUP) else @OrderNum end)
              ,[MEMO] = @MEMO
           WHERE GOODS_GROUP_ID = @GOODS_GROUP_ID";

        #endregion

        #region LOGIC_DELETE_GOODS_GROUP_SQL

        private const string _logic_DELETE_GOODS_GROUP_SQL = @"UPDATE [M006_GOODS_GROUP]
           SET [UPDATE_DATETIME] = CONVERT(VARCHAR,GETDATE(),112) + REPLACE(CONVERT(VARCHAR,GETDATE(),108),':','')
              ,[TRANS_STATE] = '3'
              ,[UPDATER_ID] = @UPDATER_ID
              ,[TERMINAL_CD] = @TERMINAL_CD
           WHERE GOODS_GROUP_ID = @GOODS_GROUP_ID";

        #endregion

        #region DELETE_GOODS_NO_SQL

        private const string _delete_GOODS_NO_SQL = @"Delete From M013_GoodSNo Where ID = @ID";

        #endregion

        #region PHYSICAL_DELETE_GOODS_GROUP_SQL

        private const string _physical_DELETE_GOODS_GROUP_SQL = @"DELETE FROM [M006_GOODS_GROUP]           
           WHERE GOODS_GROUP_ID = @GOODS_GROUP_ID";

        #endregion

        #endregion

        #region Property
        /// <summary>
        /// Exist_GOODS_GROUP_SQL
        /// </summary>
        public static string Exist_GOODS_GROUP_SQL
        {
            get
            {
                return _exist_GOODS_GROUP_SQL;
            }
        }
        /// <summary>
        /// Get_Single_Data_SQL
        /// </summary>
        public static string Get_Single_Data_SQL
        {
            get
            {
                return _get_Single_Data_SQL;
            }
        }
        /// <summary>
        /// Check_Name_SQL
        /// </summary>
        public static string Check_Name_SQL
        {
            get
            {
                return _check_Nmae_SQL;
            }
        }
        /// <summary>
        /// Goods_Group_Delete_Check_SQL
        /// </summary>
        public static string Goods_Group_Delete_Check_SQL
        {
            get
            {
                return _goods_Group_Delete_Check_SQL;
            }
        }

        /// <summary>
        /// Insert_GOODS_GROUP_SQL
        /// </summary>
        public static string Insert_GOODS_GROUP_SQL
        {
            get
            {
                return _insert_GOODS_GROUP_SQL;
            }
        }

        /// <summary>
        /// insert_GOODS_NO_SQL
        /// </summary>
        public static string Insert_GOODS_NO_SQL
        {
            get { return _insert_GOODS_NO_SQL; }
        }

        /// <summary>
        /// Update_GOODS_GROUP_SQL
        /// </summary>
        public static string Update_GOODS_GROUP_SQL
        {
            get
            {
                return _update_GOODS_GROUP_SQL;
            }
        }
        /// <summary>
        /// Logic_Delete_GOODS_GROUP_SQL
        /// </summary>
        public static string Logic_Delete_GOODS_GROUP_SQL
        {
            get
            {
                return _logic_DELETE_GOODS_GROUP_SQL;
            }
        }

        /// <summary>
        /// Delete_GOODS_NO_SQL
        /// </summary>
        public static string Delete_GOODS_NO_SQL
        {
            get
            {
                return _delete_GOODS_NO_SQL;
            }
        }

        /// <summary>
        /// Physical_Delete_GOODS_GROUP_SQL
        /// </summary>
        public static string Physical_Delete_GOODS_GROUP_SQL
        {
            get
            {
                return _physical_DELETE_GOODS_GROUP_SQL;
            }
        }

        #endregion 
    }
}
